import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
import { uploadMyFile } from '/@/api/common/api';

const { createMessage } = useMessage();

enum Api {
  listPage = '/act/task/todo/listPage',
  taskClaim = '/act/task/todo/taskClaim',
  taskTransfer = '/act/task/todo/taskTransfer',
  convertToModel = '/act/task/todo/convertToModel',
  deleteOne = '/act/task/todo/delete',
  endOne = '/act/task/todo/endProcess',
  getFlowchart = '/act/task/todo/resourceImage',
}

/**
 * 列表接口
 * @param params
 */
export const listPage = (params) => defHttp.get({ url: Api.listPage, params });

/**
 * 任务签收
 * @param params
 * @param handleSuccess
 */
export const taskClaim = (params, handleSuccess) => {
  return defHttp.get({ url: Api.taskClaim, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

/**
 * 任务转办
 * @param params
 * @param handleSuccess
 */
export const taskTransfer = (params, handleSuccess) => {
  return defHttp.get({ url: Api.taskTransfer, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}

export const getFlowchart = (params, handleSuccess) => {
  return defHttp.get({ url: Api.getFlowchart, params }).then(res => {
    handleSuccess(res);
  });
}
